<?php 
include '../../../php/conn.php'; 
if ($con) {
	if ($_POST) {
		
		//添加级数
		$DTTheName= $_POST['DTTheName'];
		 
		 $DTTime = date('y-m-d H:I:S');
	 //查询是否添加过
 
		$masql = "SELECT * FROM departmenttable WHERE DTTheName='$DTTheName'"; 
		$msy=mysql_query($masql); 
		if ($msy) {
			$mynamesql = mysql_num_rows($msy);
			if ($mynamesql==1) {
				 
				//已有该数据
				echo '{"status":"100"}';
				
			} else {
				 
				 //没有此数据时执行新增
				$sql = "INSERT INTO `departmenttable`(`DTid`, `DTTheName`, `DTTime`) VALUES (0,'$DTTheName','$DTTime')";
				//执行
				$rs = mysql_query($sql);
				if ($rs) { 
					 //新增成功 
					 echo '{"status":"200"}';
				}else
					{
						//新增失败
				echo '{"status":"404"}';
				
					} 
			} 

		} else {
			//sql语句错误
			echo '{"status":"501"}';
		}
	 
	}  
	 
}
//关闭数据库
mysql_close($con);
?>